<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
  <base href="${path}/">
  <meta charset="utf-8">
  <title>学生管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="layuiadmin/style/login.css" media="all">
</head>
<body>

  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>学生管理系统</h2>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
          <input type="text" name="uname" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
          <input type="password" name="passwd" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
        </div>
       
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-submit">登 入</button>
        </div>        
      </div>
    </div>
    
  </div>
  
  <script src="./layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: './layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function() {
	var form = layui.form;
	var layer = layui.layer;
	var $ = layui.$;
	  
	// 提交表单
	form.on('submit(LAY-submit)', function(obj){
		// 发送ajax请求
		$.post('${path}/action/user/login', obj.field, function(ret) {
			if(!ret.success) {
				layer.msg("登录失败：" + ret.msg, {icon: 5});
			} else {
				// 页面跳转
				window.location.href = 'index.jsp';
			}			  
		});  
	})	  
  });  
  
  </script>

</body>
</html>